package com.example.leetcode.niuke;

import java.util.Scanner;

public class NiuKe2 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int i1 = scanner.nextInt();
            System.out.println(convert(i1));
        }
    }

    public static double convert(int i ) {
        int count = 0;
        double r = 0;
        while ( i  > 0) {
            int i1 = i % 10;
            if (i1 >4) {
                i1--;
            }
            double v = i1 * Math.pow(9, count);
            r += v;
            i = i / 10;
            count++;
        }
        return r;
    }
}
